package cn.kgc.util;

import cn.kgc.entity.Student;

import java.util.List;

public class Page {
    // 当前页
    private int currentPageNo;
    // 总页数
    private int countPageNo;
    // 总记录数
    private int countNo;
    // 放学生对象
    private List<Student> studentList;

    public Page() {
    }

    public Page(int currentPageNo, int countPageNo, int countNo, List<Student> studentList) {
        this.currentPageNo = currentPageNo;
        this.countPageNo = countPageNo;
        this.countNo = countNo;
        this.studentList = studentList;
    }

    public int getCurrentPageNo() {
        return currentPageNo;
    }

    public void setCurrentPageNo(int currentPageNo) {
        if (currentPageNo > 0 && currentPageNo <= countPageNo) {
            this.currentPageNo = currentPageNo;
        }
    }

    public int getCountPageNo() {
        return countPageNo;
    }

    public int getCountNo() {
        return countNo;
    }

    public void setCountNo(int countNo) {
        this.countNo = countNo;
        this.countPageNo = countNo % Constands.PAGE_SIZE == 0 ? countNo / Constands.PAGE_SIZE : countNo / Constands.PAGE_SIZE + 1;
    }

    public List<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }

    @Override
    public String toString() {
        return "Page{" +
                "currentPageNo=" + currentPageNo +
                ", countPageNo=" + countPageNo +
                ", countNo=" + countNo +
                ", studentList=" + studentList +
                '}';
    }
}
